#ifndef LV_PORT_H
#define LV_PORT_H

#include "esp_lcd_touch_gt911.h"

#define CONFIG_LCD_I80_COLOR_IN_PSRAM 1 /* use PSRAM as lvgl buff */
#define CONFIG_LCD_I80_BUS_WIDTH 8      /* use 8bit DATA */

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if CONFIG_LCD_I80_COLOR_IN_PSRAM
// PCLK frequency can't go too high as the limitation of PSRAM bandwidth
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (20 * 1000 * 1000) /* use psram as lvgl buff */
#else
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (30 * 1000 * 1000) /* use sram as lvgl buff */
#endif

#define EXAMPLE_PIN_NUM_DATA0 9
#define EXAMPLE_PIN_NUM_DATA1 8
#define EXAMPLE_PIN_NUM_DATA2 7
#define EXAMPLE_PIN_NUM_DATA3 6
#define EXAMPLE_PIN_NUM_DATA4 5
#define EXAMPLE_PIN_NUM_DATA5 4
#define EXAMPLE_PIN_NUM_DATA6 3
#define EXAMPLE_PIN_NUM_DATA7 2
#if CONFIG_LCD_I80_BUS_WIDTH > 8
#define EXAMPLE_PIN_NUM_DATA8 -1
#define EXAMPLE_PIN_NUM_DATA9 -1
#define EXAMPLE_PIN_NUM_DATA10 -1
#define EXAMPLE_PIN_NUM_DATA11 -1
#define EXAMPLE_PIN_NUM_DATA12 -1
#define EXAMPLE_PIN_NUM_DATA13 -1
#define EXAMPLE_PIN_NUM_DATA14 -1
#define EXAMPLE_PIN_NUM_DATA15 -1
#endif
#define EXAMPLE_PIN_NUM_PCLK 12
#define EXAMPLE_PIN_NUM_CS 14
#define EXAMPLE_PIN_NUM_DC 13
#define EXAMPLE_PIN_NUM_RST 10
#define EXAMPLE_PIN_NUM_RD 11
#define EXAMPLE_PIN_NUM_BK_LIGHT 1

// The pixel number in horizontal and vertical
#define EXAMPLE_LCD_H_RES 800
#define EXAMPLE_LCD_V_RES 480
// Bit number used to represent command and parameter
#define EXAMPLE_LCD_CMD_BITS 16
#define EXAMPLE_LCD_PARAM_BITS 16

#define EXAMPLE_LVGL_TICK_PERIOD_MS 2

// Supported alignment: 16, 32, 64. A higher alignment can enables higher burst transfer size, thus a higher i80 bus throughput.
#define EXAMPLE_PSRAM_DATA_ALIGNMENT 64

#if CONFIG_LCD_I80_COLOR_IN_PSRAM
#define LVGL_BUFF_SIZE (EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES) /* screen sized */
#else
#define LVGL_BUFF_SIZE ((EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES) / 30) /* 1/30 screen sized */
#endif

#ifdef __cplusplus
extern "C"
{
#endif

    void lv_gui_task(void *arg);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
